import request from "../request";
import type { IAdminListParams, roleListRes, roleListItem, getRoleInfoItem } from "@/types/global";

// 创建角色
interface createRoleRes {
	code: number;
	data: number;
	message: string;
}
// 修改状态
interface updateStatusParams {
	id: number;
	status: number;
}

// 角色列表
export const roleListAPI = (data?: IAdminListParams): Promise<roleListRes> => request.get("/role/list", { params: data });
// 修改角色
export const updatedRoleAPI = (params: roleListItem): Promise<createRoleRes> => request.post(`role/update/${params.id}`, params);
// 创建角色
export const createRoleAPI = (data?: roleListItem): Promise<createRoleRes> => request.post("/role/create", data);
// 修改角色状态
export const updatedStatusAPI = (data: updateStatusParams) => request.post(`/update/${data.id}?status=${data.status}`);
// 获取所有角色
export const getListAllAPI = (): Promise<getRoleInfoItem[]> => request.get("/role/listAll");
// 指定用户菜单
export const getListMenuAPI = (roleId: number): Promise<getRoleInfoItem[]> => request.get(`/role/listMenu/${roleId}`);
